<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            list-style: none;
        }
        .box{
            width: 300px;
            height: 300px;
            border: 1px solid #ccc;
            margin: auto;
        }
        .head{
            width: 300px;
            height: 50px;
            background: rgb(19, 155, 189);
        }
        .bon{
            width: 300px;
            height: 250px;
        }
        .on{
            background: orange;
        }
        li{
            float: left;
            line-height: 50px;
            margin-left: 35px;
            color: #fff;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="head">
            <li></li>
        </div>
        <div class="bon">

        </div>
    </div>
    <script>
        let arr=[{name:'零零零',count:'12345'},
        {name:'哒哒哒',count:'741852'},
        {name:'啧啧啧',count:'963852'}]

        class Tab{
            constructor(){
                this.data=arr;
                this.head=document.querySelector('.head');
                this.bon=document.querySelector('.bon');
                this.render();
                this.bindEvent();
            }
            render(){
                this.head.innerHTML=this.data.map((x,y)=>{
                    return `
                        <li class="${y==0 ?'on':''}">${x.name}</li>
                    `
                }).join('')
            }
            bindEvent(){
                let lis=[...document.querySelectorAll('li')];
                lis.map((x,y)=>{
                    x.onclick=()=>{
                        this.bon.innerHTML=this.data[y].count;
                        document.querySelector('.on').classList.remove('on');
                        x.classList.add('on');
                    }
                })
            }
        }
        new Tab();
    </script>
</body>
</html>